/****************************************************************
* @file   : vpcie.hpp
* @author : NingJian (freegodly@gmail.com)
* @date   : 05/26/21 09:37:58
* @brief   : 
****************************************************************/
#pragma once

#include <cstdint>
#include <cstddef>



#define __PCIE_MEM__  

enum pcieError_t{
    OK,
    ERR
};


struct CacheConf {

};

pcieError_t pcieSetDevice(size_t dev_index);


pcieError_t pcieSetDeviceFlags(uint32_t flags);

pcieError_t pcieDeviceSetCacheConfig(CacheConf cc);


pcieError_t pcieDeviceSynchronize();


pcieError_t pcieDeviceReset();

pcieError_t pcieMalloc(void ** out , size_t length);

pcieError_t pcieMemcpy(void * dest ,void * src, size_t length);


pcieError_t pcieMemcpyToSymbolA(void * symbol,const void* src, size_t count, size_t offset);

template<class T>
static  pcieError_t pcieMemcpyToSymbol(
    const T                   &symbol,
    const void                *src,
    size_t                    count,
    size_t                    offset = 0
    )
{
  return pcieMemcpyToSymbolA((void*)&symbol, src, count, offset);
}


pcieError_t pcieMemcpyFromSymbolA(void * dst,const void* symbol, size_t count, size_t offset);

template<class T>
static  pcieError_t pcieMemcpyFromSymbol(
        void                *dst,
        const T              &symbol,
        size_t               count,
        size_t               offset = 0
)
{
  return pcieMemcpyFromSymbolA(dst, (const void*)&symbol, count, offset);
}


